<%--
  Created by IntelliJ IDEA.
  User: xiaoji
  Date: 2015/1/7
  Time: 9:28
  To change this template use File | Settings | File Templates.
--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
<head>
    <title><spring:message code='usercenter.index.title' /></title>
    <link href="${path}/style/acg/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${path}/js/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<jsp:include page="../public/header.jsp"></jsp:include>
<jsp:include page="../usercenter/leftMenu.jsp"></jsp:include>
<div class="member_box">
    <div class="member_title">
        <spring:message code='memrace.principalIndex.msg1' />
    </div>
    <div class="member_message" id="messages">
    </div>
    <div id="kkpager" style="text-align: center;margin-bottom: 15px;"></div>
</div>
<link href="${path}/plugins/page/kkpager.css" rel="stylesheet">
<script src="${path}/plugins/page/kkpager.js" type="text/javascript"></script>
<script>
    var pageSize = 10;
    function initBeanInfo(page, rows) {
        //异步获取生产计划
        pageSize = rows;
        $.post("${path}/memrace/getPrincipalRace.html", {
            page: page,
            rows: rows
        }, function (data) {
            var list = data.pageInfo.list;
            var htmlstr = "<ul>";
            if (list != null) {
                for (var i = 0; i < list.length; i++) {
                    var obj = list[i];
                    if(obj.name == undefined){
                        obj.name = "";
                    }
                    htmlstr+='<li class="clearfix" style="cursor:pointer" onclick="window.location=\'${path}/racedetail/index.html?raceId='+obj.raceId+'\'">'+
                            '<img src="${path}/'+obj.pic+'" width="70" height="70" class="uimg" onerror="javascript:this.src=\'${path}/style/common/images/headimg.jpg\'"/>'+
                            '<div class="txt">'+
                            '<h3>'+obj.title;
                    htmlstr+='<em><font>'+obj.progressName+'</font></em>' ;
                    var date1 = "";
                    if(obj.startTime != undefined){
                        date1 = obj.startTime
                    }
                    var date2 = "";
                    if(obj.endTime != undefined){
                        date2 = obj.endTime
                    }
                    htmlstr+='<span><spring:message code='memrace.principalIndex.msg2' />'+date1+"&nbsp;&nbsp;<spring:message code='memrace.artistIndex.msg6' />&nbsp;&nbsp;"+date2+
                            '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="${path}/racedetail/index.html?raceId='+obj.raceId+'"><spring:message code='memrace.artistIndex.msg4' /></a></span> </h3>'+
                            '<div class="msg_con">'+obj.name+ ' </div>'+
                            '</div>'+
                            ' </li>';
                }
                htmlstr+='</ul>';
                $("#messages").html(htmlstr);
                var pager = data.pageInfo;
                //分页
                createPage(pager.pageNum, pager.pages, pager.total);
            }

        },"json");
    }

    //分页方法
    //currentPage 当前页
    //rows 每页条数
    //total 总数
    function createPage(currentPage, totalPage, totalCount) {
        var totalPage = totalPage;
        var totalRecords = totalCount;
        var pageNo = currentPage;
        if (!pageNo) {
            pageNo = 1;
        }
        //生成分页
        //有些参数是可选的，比如lang，若不传有默认值
        kkpager.generPageHtml({
            pno: pageNo,
            //总页码
            total: totalPage,
            //总数据条数
            totalRecords: totalRecords,
            //链接前部
            hrefFormer: 'index',
            //链接尾部
            hrefLatter: '',
            //是否显示总页数
            isShowTotalPage: true,
            //是否显示总记录数
            isShowTotalRecords: true,
            //是否显示页码跳转输入框
            isGoPage: true,
            //getLink: function (n) {
            //    return this.hrefFormer + this.hrefLatter + "?pno=" + n;
            //}
            //,
            mode : 'click',//默认值是link，可选link或者click
            click : function(n){
                //this.selectpage(n);
                initBeanInfo(n, pageSize);
                return false;
            },
            lang				: {
                firstPageText			: '<spring:message code="firstPageText"/>',
                firstPageTipText		: '<spring:message code="firstPageTipText"/>',
                lastPageText			: '<spring:message code="lastPageText"/>',
                lastPageTipText			: '<spring:message code="lastPageTipText"/>',
                prePageText				: '<spring:message code="prePageText"/>',
                prePageTipText			: '<spring:message code="prePageTipText"/>',
                nextPageText			: '<spring:message code="nextPageText"/>',
                nextPageTipText			: '<spring:message code="nextPageTipText"/>',
                totalPageBeforeText		: '<spring:message code="totalPageBeforeText"/>',
                totalPageAfterText		: '<spring:message code="totalPageAfterText"/>',
                totalRecordsAfterText	: '<spring:message code="totalRecordsAfterText"/>',
                gopageBeforeText		: '<spring:message code="gopageBeforeText"/>',
                gopageButtonOkText		: '<spring:message code="gopageButtonOkText"/>',
                gopageAfterText			: '<spring:message code="gopageAfterText"/>',
                buttonTipBeforeText		: '<spring:message code="buttonTipBeforeText"/>',
                buttonTipAfterText		: '<spring:message code="buttonTipAfterText"/>'
            }
        },true);
    }
    $(function(){
        initBeanInfo(1,10);
    });
</script>
<jsp:include page="../usercenter/leftMenuEnd.jsp"></jsp:include>
<jsp:include page="../public/footer.jsp"></jsp:include>
</body>
</html>
